import {
  Column,
  CreateDateColumn,
  PrimaryGeneratedColumn,
  UpdateDateColumn,
} from 'typeorm';

export class Cart {
  @PrimaryGeneratedColumn('increment', { comment: '自增主键', unsigned: true })
  id: number;

  @Column({ comment: '用户ID' })
  userId: number;

  @Column({ comment: '商品ID' })
  productId: number;

  @Column({ comment: '选购数量' })
  quantity: number;

  @Column({ comment: '单价' })
  price: number;

  // 规格{ name: 'xxxx', price: 100, stock: 1000 }
  @Column({ comment: '选中规格' })
  spec: string;

  @Column({ comment: '是否勾选', type: 'tinyint', default: false })
  checked: boolean;

  @CreateDateColumn({ comment: '加入时间' })
  created: Date;

  @UpdateDateColumn({ comment: '更新时间' })
  updated: Date;
}
